package redisinit

import (
	"fmt"
	"github.com/go-redis/redis"
	"wangwang/appconfig"
)

var (
	Client *redis.Client
)

func InitRedis() {
	RedisConf := appconfig.AppConf.RedisConfig
	Client = redis.NewClient(&redis.Options{
		Addr:     RedisConf.Addr,
		Password: RedisConf.Password, // no password set
		DB:       RedisConf.Db,       // use default DB
	})

	_, err := Client.Ping().Result()
	if err != nil {
		fmt.Println("redis连接失败", err)
		return
	}
	fmt.Println("redis连接成功")
}
